<?php
require("interface.php");


//处理七天前的记录
$log_time = date('Y-m-d H:i:s');
$new_time=date('Y-m-d',strtotime('-7 day',strtotime("$log_time")));
$sql_del = "delete from dlz_sync_ordernums where updatetime <='$new_time'";
echo "----删除日志记录--$sql_del----";
$db->exec($sql_del);

$new_times=date('Y-m-d',strtotime('-28 day',strtotime("$log_time")));
$sql_del_post_tracnumber_record = "delete from dlz_post_tracnumber_record where updatetime <='$new_times'";
echo "----删除推送单号到magento日志记录--$sql_del_post_tracnumber_record----";
$db->exec($sql_del_post_tracnumber_record);

//删除同步记录
$new_times=date('Y-m-d',strtotime('-28 day',strtotime("$log_time")));
$sql_del_post_tracnumber_record = "delete from dlz_post_record_status where updatetime <='$new_times'";
echo "----删除推送单号到magento日志记录--$sql_del_post_tracnumber_record----";
$db->exec($sql_del_post_tracnumber_record);

 /*****额外处理状态****/
   // 有些产品已经插入成功，但是状态为改变，未查到原因，因此先暴力解决下，7
$new_time=date('Y-m-d',strtotime('-2 day',strtotime("$log_time")));   
$syncstatus_sql = "update dlz_attribute_all_id set sync_status='7' where updatetime <='$new_time'";
$db->exec($syncstatus_sql);
echo "----更改状态记录--$syncstatus_sql----";
/***处理订单异常，长期未处理，会导致推送时，数据过多，造成效率低下，因此再次处理一个月以上的单子修改为3***/
$new_time=date('Y-m-d',strtotime('-28 day',strtotime("$log_time")));  
$orderinfo_post_status = "update dlz_order_info set post_status='1' where updatetime <='$new_time'";
$db->exec($orderinfo_post_status);
//关闭数据库
$db = null;
?>